

<?php
if ($this->code == "0"){
    echo "<legend>";
    echo $this->msg;
    echo "</legend>";
}else echo $this->msg;

if ($this->code == ""){
?>

<legend>Bayar Tagihan PLN</legend>
<div class="row clearfix">
<div class="col-md-8 column">
    <form method="post" id="frm" name="frm">
  
                <!-- Member form -->

                
                <?php //echo $this->today; ?>
                
                <h4>Data Pembayaran:</h4>
                
                <!-- fromAcc input-->
                <div class="form-group">
                    <label class="control-label">Dari Rekening</label>
                    
                        <select id="fromAcc" name="fromAcc" class="form-control">
                            <?php
                            
                           foreach ($this->accountList as $oAcc) {
                                    echo "<option value='".$oAcc['bank_account_no']."'>". $oAcc['bank_name'] .' '. $oAcc['bank_account_no'] ." (". $oAcc['account_name'] .")</option>";
                           }
                           ?>
                        </select>
                        <p class="help-block"></p>
                    
                </div>
                <br>
                <h4>Untuk Pembayaran:</h4>

                <!-- from_list input-->
                <div class="form-group">
                    <label class="control-label"><input type="radio" id="fromRadio" name="fromRadio" value="1" onclick="pilihRek(this)"/> Dari Daftar Pribadi</label>
                    
                        <select id="from_list" name="from_list" class="form-control" disabled required>
                           <option value=''>== Pilih ==</option>
                            <?php
                           foreach ($this->accPersonalList as $oAcc) {
                                    echo "<option value='".$oAcc['phone_num']."'>". $oAcc['phone_num'] ."</option>";
                           }
                           ?>
                        </select>
                        <p class="help-block"></p>
                    
                </div>

   

                <!-- no_pln input-->
                <div class="form-group">                    
                        <label class="control-label"><input type="radio" id="fromRadio" name="fromRadio" value="2" onclick="pilihRek(this)"/> Isi Nomor PLN</label>
                        <input id="no_pln" name="no_pln" type="text" placeholder="Nomor PLN"
                        class="form-control" disabled required>
                        <p class="help-block">Pastikan No. PLN yang Anda masukan benar. Transaksi yang telah dikirim tidak dapat dibatalkan.</p>
                    
                </div>

               
                <!-- saveAs input-->
                <div class="form-group">
                        <label class="control-label"><input type="checkbox" id="cbSave" name="cbSave" disabled onchange="klikSave(this)"/> Simpan dalam daftar pribadi</label>
                        <input id="saveAs" name="saveAs" type="text" placeholder="Simpan Sebagai"
                        class="form-control" disabled required>
                        <p class="help-block"></p>
                </div>

                <!-- remark input-->
                <div class="form-group">
                    
                    <div class="controls">
                        <textarea id="remark" name="remark" type="text" placeholder="Catatan"
                        class="form-control"></textarea>
                        
                        <p class="help-block"></p>
                    </div>
                </div>

                <!-- submit btn-->
                <div class="form-group">
                    <label class="control-label"></label>
                    <div class="controls">
                        <button class="btn btn-default" type="submit" id="btnSubmit" name="btnSubmit">
                        Submit</button> <div id="div_result"></div>
                        <p class="help-block"></p>
                    </div>
                </div>

        </form>
</div>
</div>

        <script>

        function pilihRek(obj){

            if (obj.value == "1"){
                $("#from_list").removeAttr('disabled');

                $("#no_pln").val('');
                $("#no_pln").attr('disabled','disabled');


                $("#cbSave").removeAttr('checked');
                $("#cbSave").attr('disabled','disabled');

            }else{

                $("#from_list").attr('disabled','disabled');

                $("#no_pln").removeAttr('disabled');
                $("#cbSave").removeAttr('disabled');
                
            }
        }

        function klikSave(obj){
            if(obj.checked){
                $("#saveAs").removeAttr('disabled');
            }else{
                $("#saveAs").val('');
                $("#saveAs").attr('disabled','disabled');
            }
        }

        function validateNumber(evt) {

            var charCode = (evt.which) ? evt.which : event.keyCode
            if (charCode > 31 && (charCode < 48 || charCode > 57))
                return false;
            return true;
          }

        /* Attach a submit handler to the form */
        $("#frm").submit(function(event) {

            /* Stop form from submitting normally */
            event.preventDefault();

            /* Clear result div*/
            $("#div_result").html('');
            $("#btnSubmit").html('Memproses...');
            $("#btnSubmit").attr('disabled','disabled');

            /* Get some values from elements on the page: */
            var values = $(this).serialize();
            var msg = [];
            
            /* Send the data using post and put the results in a div */

            $.ajax({
                url: "<?php echo $this->baseUrl() ?>/purchase/plnpay/",
                type: "post",
                data: values,
                success: function(response, opts){
                    var cekSess = response.toUpperCase().search("SESSION TIMEOUT");

                    if (cekSess < 0){
                        var cekStatus = response.toUpperCase().search("ERROR");

                        if (cekStatus < 0){
                            $("#div_content").html(response);
                        }else{
                            var resp = response.replace('ERROR', '');

                            msg.push('<span>'+resp+'</span>');
                            $.messager.alert('Info', msg.join('<br/>'));

                            //$("#div_result").html(resp);
                            $("#btnSubmit").removeAttr('disabled');
                            $("#btnSubmit").html('Submit');
                        }
                    }else{
                        location.href='<?php echo $this->baseUrl() ?>/index/login/msg/Session Timeout silahkan login kembali !';
                    }
                },
                error:function(response, opts){
                    //alert("failure");
                    msg.push('<span>'+response+'</span>');
                    $.messager.alert('Info', msg.join('<br/>'));

                    $("#btnSubmit").removeAttr('disabled');
                }
            });

        });

        </script>

        <?php } ?>
    